import java.util.Arrays;
import java.util.Scanner;

//获取密码
public class PassWord {

    private int passWord;
    int errNum = 0;

    //接收密码
    public void inPut() {

        int count = 0;
        if (errNum == 0) {
            System.out.println("欢迎使用加密程序");
            System.out.println("输入4位数密码 ->");

        }
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
//        if(num == 0) {
//            System.out.println("退出加密程序");
//        }
        passWord = num;
        while(num % 10 != 0) {
            count++;
            num /= 10;
        }
        //int[] arr = new int[4];
        if (passWord != 0) {
            while (true) {
                if(errNum == 3) {
                    errNum++;
                    System.out.println("忘记密码，输入0退出");
                    System.out.println("密码格式错误，重新输入->");
                    inPut();

                }else if(count != 4){
                    errNum++;
                    System.out.println("密码格式错误，重新输入->");
                    inPut();
                }else {

                    int token = encrypt(passWord);
                    System.out.println("加密后的密码是"+token);
                    break;
                }
            }
        }else {
            System.out.println("退出加密程序");

        }
    }
    //加密
    private int encrypt(int passWord) {
        for (int i = 0; i < 3;i++) {
            String[] strings = new String[]{"。","。。","。。。"};
            try {
                System.out.println("正在加密中" + strings[i]);
                Thread.sleep(1000);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        int[] arr = new int[4];
        int num = 0;
        String snum = new String();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = passWord % 10;
            snum += (char)arr[i];
            //num += arr[i]*Math.pow(10,i);
            passWord /= 10;
        }

        return num;
    }


    //主函数
    public static void main(String[] args) {
        PassWord passWord = new PassWord();
        passWord.inPut();
//        System.out.println(Math.pow(1,2));
    }

}
